﻿@namespace MudBlazor.Docs.Examples

<MudGrid>
    <MudItem xs="12" md="3">
        <MudForm>
            <MudSwitch T="bool" CheckedChanged="@OnPostitionChange" Color="Color.Primary" Label="Open Top" />
            <MudSwitch @bind-Checked="@OffsetY" Color="Color.Secondary" Label="Offset Y" />
            <MudSwitch @bind-Checked="@Dense" Color="Color.Primary" Label="Dense" />
        </MudForm>
    </MudItem>
    <MudItem xs="12" md="1" />
    <MudItem xs="12" md="4">
        <MudSelect T="string" Label="Variants" Variant="@_variant" Direction="@_direction" Dense="@Dense" OffsetY="@OffsetY" ValueChanged="OnSelectedValue">
            <MudSelectItem T="string" Value="@("text")">Text</MudSelectItem>
            <MudSelectItem T="string" Value="@("filled")">Filled</MudSelectItem>
            <MudSelectItem T="string" Value="@("outlined")">Outlined</MudSelectItem>
        </MudSelect>
    </MudItem>
    <MudItem xs="12" md="4" />
</MudGrid>

@code {

    public bool OpenTop { get; set; }
    public bool OffsetY { get; set; } = true;
    public bool Dense { get; set; } = true;

    public string variant { get; set; }

    public Direction _direction {get; set;}
    public Variant _variant { get; set; } = Variant.Filled;

    protected void OnPostitionChange()
    {
        OpenTop = !OpenTop;

        if (OpenTop)
        {
            _direction = Direction.Top;
        }
        else
        {
            _direction = Direction.Bottom;
        }
    }

    private void OnSelectedValue(string value)
    {
        if(value == "text")
        {
            _variant = Variant.Text;
        }
        if (value == "filled")
        {
            _variant = Variant.Filled;
        }
        if (value == "outlined")
        {
            _variant = Variant.Outlined;
        }
    }
}